package org.emergency.framework.model;

import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.OneToMany;
import javax.persistence.Table;

import org.emergency.framework.constant.ModelConstant;

/**
 * TbEntity entity. 
 */
@Entity
@Table(name = "TB_ENTITY", catalog = ModelConstant.DB_CATALOG)
public class TbEntity implements java.io.Serializable {
	private static final long serialVersionUID = 6864575404006089507L;

	@Id
	@Column(name = "TB_ENTITY_ID", unique = true, nullable = false, length = ModelConstant.STRING_LENGHT_id)
	private String tbEntityId;
	
	@Column(name = "name", length = ModelConstant.STRING_LENGHT_1)
	private String name;
	
	@Column(name = "isEnabled")
	private boolean isEnabled;
	

	//以下为备用字段
	@Column(name="a",nullable=true,length=ModelConstant.STRING_LENGHT_1)
	private String a;
	
	@Column(name="b",nullable=true,length=ModelConstant.STRING_LENGHT_1)
	private String b;
	
	@Column(name="c",nullable=true,length=ModelConstant.STRING_LENGHT_1)
	private String c;
	
	@Column(name="e",nullable=true,length=ModelConstant.STRING_LENGHT_1)
	private String e;
	
	@Column(name="d",nullable=true,length=ModelConstant.STRING_LENGHT_1)
	private String d;
	//以上为备用字段
	
	
	@OneToMany(cascade = CascadeType.ALL, fetch = FetchType.LAZY, mappedBy = "tbEntity")
	private Set<TbUserRoleEntity> tbUserRoleEntities = new HashSet<TbUserRoleEntity>(
			0);

	/** default constructor */
	public TbEntity() {
	}

	/** minimal constructor */
	public TbEntity(String tbEntityId) {
		this.tbEntityId = tbEntityId;
	}

	/** full constructor */
	public TbEntity(String tbEntityId, String name,
			Set<TbUserRoleEntity> tbUserRoleEntities) {
		this.tbEntityId = tbEntityId;
		this.name = name;
		this.tbUserRoleEntities = tbUserRoleEntities;
	}

	@Override
	public int hashCode() {
		final int prime = 31;
		int result = 1;
		result = prime * result + ((tbEntityId == null) ? 0 : tbEntityId.hashCode());
		return result;
	}

	@Override
	public boolean equals(Object obj) {
		if (this == obj)
			return true;
		if (obj == null)
			return false;
		if (getClass() != obj.getClass())
			return false;
		TbEntity other = (TbEntity) obj;
		if (tbEntityId == null) {
			if (other.tbEntityId != null)
				return false;
		} else if (!tbEntityId.equals(other.tbEntityId))
			return false;
		return true;
	}
	
	
	// Property accessors
	public String getTbEntityId() {
		return this.tbEntityId;
	}

	public void setTbEntityId(String tbEntityId) {
		this.tbEntityId = tbEntityId;
	}
	
	public String getName() {
		return this.name;
	}

	public void setName(String name) {
		this.name = name;
	}

	public Set<TbUserRoleEntity> getTbUserRoleEntities() {
		return this.tbUserRoleEntities;
	}

	public void setTbUserRoleEntities(Set<TbUserRoleEntity> tbUserRoleEntities) {
		this.tbUserRoleEntities = tbUserRoleEntities;
	}

	public boolean isEnabled() {
		return isEnabled;
	}

	public void setEnabled(boolean isEnabled) {
		this.isEnabled = isEnabled;
	}

	public static long getSerialversionuid() {
		return serialVersionUID;
	}

	public String getA() {
		return a;
	}

	public void setA(String a) {
		this.a = a;
	}

	public String getB() {
		return b;
	}

	public void setB(String b) {
		this.b = b;
	}

	public String getC() {
		return c;
	}

	public void setC(String c) {
		this.c = c;
	}

	public String getE() {
		return e;
	}

	public void setE(String e) {
		this.e = e;
	}

	public String getD() {
		return d;
	}

	public void setD(String d) {
		this.d = d;
	}
	

	
}